<template>
	<component :is="MyForm" ref="adminForm" :formData="formData" :rules="rules" :save="save" />
</template>

<script setup>
import MyForm from './components/form'
import { reactive, ref, useTemplateRef } from 'vue'
import { createFormData, createRules, addOrUpdate } from './data'
const props = defineProps(['editProps', 'getTable'])
const id = props.editProps.id
const formData = reactive(await createFormData(id))
const rules = createRules(id)
const formObj = useTemplateRef('adminForm')
function save () {
	addOrUpdate(id, formData, content => {
		props.editProps.show = false
		props.getTable()
	}, formObj.value.formRef)
}
</script>

<style scoped lang="scss">
</style>